package com.lance.answer.gui.answer.gk.answer.lms.batch;

import com.lance.answer.gui.answer.gk.answer.lms.batch.dto.LmsWatchDTO;
import com.lance.answer.gui.answer.gk.answer.lms.batch.task.LmsSaveVideoTask;
import com.lance.answer.gui.answer.gk.answer.lms.util.LmsUtil;
import org.apache.commons.io.IOUtils;

import java.io.FileInputStream;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import java.util.concurrent.LinkedBlockingDeque;

public class LmsSaveVideoTmpppppppp2 {

    public static void main(String[] args) throws Exception {


        int sync = 6;

        LinkedBlockingDeque<LmsWatchDTO> watchQueue = new LinkedBlockingDeque<>();

        InputStream inputStream2 = new FileInputStream("libs//2022秋//fengx.user");
        List<String> userString = IOUtils.readLines(inputStream2, "utf-8");

        for (String user : userString) {
            String[] strs = user.split(",");
            String userCode = strs[0];
            String pwd = strs[1];
            LmsWatchDTO lmsWatchDTO = new LmsWatchDTO();
            lmsWatchDTO.setUsername(userCode);
            lmsWatchDTO.setPassword(pwd);
//            if(!LmsUtil.getVip().contains(userCode)){
//                continue;
//            }
            if(
                    !"2137106402515".equals(userCode)
//                            &&!"2112001251021".equals(userCode)
//                            &&!"2112001251049".equals(userCode)
//                            &&!"2215001200361".equals(userCode)
//                            &&!"2115001201897".equals(userCode)
//                            &&!"2244001401982".equals(userCode)
            ){
                continue;
            }


            Map<Long, String> getUserCourseMap = LmsUtil.getUserCourseMap(userCode);
       //     getUserCourseMap.clear();
     //       getUserCourseMap.put(10000004773L, "社区治理");
//            lmsWatchDTO.setCourseMap(getUserCourseMap);
            lmsWatchDTO.setCourseMap(getUserCourseMap);

            watchQueue.add(lmsWatchDTO);
        }

        for (int i = 1; i <= sync; i++) {
            Thread answerThread = new LmsSaveVideoTask("d:\\ynouAutoStudy\\chromedriver.exe", watchQueue);
            //log.info("加载课程ID：{} 名称：{} ", openCourseId,subjectName);
            answerThread.setName("答题线程--" + i);
            answerThread.start();
        }


    }



}
